package com.genesis.yunnanji.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.genesis.yunnanji.Constants;

import com.genesis.yunnanji.R;
import com.genesis.yunnanji.bean.ClassifyCategoryBean;
import com.genesis.yunnanji.view.BrandDetailsActivity;
import com.youth.xframe.adapter.XRecyclerViewAdapter;
import com.youth.xframe.adapter.XViewHolder;

import java.util.List;

/**
 * 创建日期：2018/9/26 on 14:26
 * 作者:Kite
 * 描述:分类Adapter
 */
public class ClassifyChildAdapter extends XRecyclerViewAdapter<ClassifyCategoryBean.ListBean> {

    private Context mContext;

    public ClassifyChildAdapter(Context context, @NonNull RecyclerView mRecyclerView, List<ClassifyCategoryBean.ListBean> dataLists) {
        super(mRecyclerView, dataLists, R.layout.item_classify_child);
        this.mContext = context;
    }

    @Override
    protected void bindData(XViewHolder holder, final ClassifyCategoryBean.ListBean data, final int position) {
        holder.setText(R.id.tv_title_cn, data.getTitle());
        holder.setText(R.id.tv_title_en, data.getName());
        Glide.with(mContext).load(Constants.PIC_ADMIN + data.getIcon()).into((ImageView) holder.getView(R.id.icon_img));
        holder.getView(R.id.item).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, BrandDetailsActivity.class);
                intent.putExtra("p0", data.getTitle());
                intent.putExtra("p1", data.getId());
                mContext.startActivity(intent);
            }
        });
    }
}
